import request from '@/utils/request'

/**
 * 分页获取文章
 * @param {*} pageParams
 * @returns
 */
export const getArticlePageAPI = (pageParams) => {
  return request({
    url: '/article',
    method: 'get',
    params: {
      currentPage: pageParams.currentPage,
      pageSize: pageParams.pageSize,
    },
  })
}

/**
 * 发布文章
 * @param {*} pageParams
 * @returns
 */
export const publishArticleAPI = (data) => {
  return request({
    url: '/article',
    method: 'post',
    data: data,
  })
}

/**
 * 根据 id 获取文章
 */
export const getArticleByIdAPI = (id) => {
  return request({
    url: `/article/${id}`,
    method: 'get',
  })
}

/**
 * 更新文章
 */
export const updateArticleAPI = (data) => {
  return request({
    url: `/article/${data.id}`,
    method: 'put',
    data,
  })
}

/**
 * 删除文章
 * @param {*} id
 * @returns
 */
export const deleteArticleAPI = (id) => {
  return request({
    url: `/article/${id}`,
    method: 'delete',
  })
}
